<template>
  <!-- 积分申请页 -->
  <div class="box">
    <div>
      <van-cell-group>
        <van-field
          v-model="event_val"
          disabled
          label="申请事件"
          placeholder="请选择事件"
          is-link
          @click="showPopup"
        >
        </van-field>
        <van-popup
          v-model="show"
          position="top"
          :safe-area-inset-bottom="true"
          :style="{ height: '60%',paddingTop:'12px' }"
          :overlay-style="{background:'rgba(0, 0, 0, 0.34)'}"
        >
          <form action="/">
            <van-search
              v-show='search_event'
              placeholder="请输入搜索关键词"
              v-model="value"
              shape="round"
              @search="onSearch"
              @clear="onCancel"
            />
          </form>
          <div
            v-show="show_temporary_event"
            class="temporary"
            @click="show_temporary_click"
          >
            <van-icon
              style="vertical-align: middle;margin-right:5px;"
              name="warning"
            />点击此处用作临时事件
          </div>
          <div class="clearfix">
            <dl class="left">
              <dt @click="show_event_name_one">一级事件</dt>
              <dt @click="show_event_name_one">{{one_name.slice(0,6)}}</dt>
              <dd
                v-if="one_Events"            
              >
                <div style="margin:10px 0px"
                v-for="(ll,t) in event_list"
                :key='t+"--"' 
                @click="showTowEvent(ll.name,ll.id)">{{ll.name}}</div>
              </dd>
            </dl>
            <dl
              class="left"
              v-show="towEvent"
            >
              <dt @click="show_event_name_two()">二级事件</dt>
              <dt @click="show_event_name_two()"><span>></span>{{two_name.slice(0,6)}}</dt>
              <dd style="position:absolute;left:14px">
                <div
                
                  v-if="two_isInfo==0&&two_Events"
                >
                  <div
                    style="margin:10px 0px"
                    @click="showThreeEvent(ol.name,ol.id)"
                    v-for="(ol,t) in two_list"
                    :key='t+"info--"'
                  >{{ol.name}}</div>
                </div>
              </dd>
            </dl>
            <dl
              class="left"
              v-show="threeEvent"
            >
              <dt @click="show_event_name_three(three_list)">三级事件</dt>
              <dt @click="show_event_name_three(three_list)"><span>></span>{{three_name.slice(0,6)}}</dt>
              <dd style="position:absolute;left:14px">
                <div
                  v-if="three_isInfo==0"
                  v-show="three_Events"
                >
                  <div
                    style="margin:10px 0px"
                    @click="showFourEvent(ok.name,ok.id)"
                    v-for="(ok,t2) in three_list"
                    :key='t2+"infoll--"'
                  >{{ok.name}}</div>
                </div>
              </dd>
            </dl>
            <dl
              class="left"
              v-show="fourEvent"
            >
              <dt>四级事件</dt>
              <dt>{{four_name.slice(0,6)}}</dt>
              <dd style="position:absolute;left:14px">
                <div
                  v-show="four_Events"
                  v-if="four_isInfo==0"
                >
                  <div
                    style="margin:10px 0px"
                    @click="show_four_event(kl.name,kl.id)"
                    v-for="(kl,t1) in four_list"
                    :key='t1+"infoll--"'
                  >{{kl.name}}</div>
                </div>
              </dd>
            </dl>
          </div>
        </van-popup>
      </van-cell-group>
    </div>
    <van-cell-group>
      <van-field
        v-model="message"
        rows="5"
        :style="{borderTop:'1px solid silver',borderBottom:'1px solid silver'}"
        label="事件描述"
        type="textarea"
        placeholder="请输入事件描述"
        show-word-limit
      />
    </van-cell-group>
    <!-- 申请对象 -->
    <div class="van-cell-group van-hairline--top-bottom">
      <div class="van-cell van-cell--clickable van-field">
        <div class="van-cell__title van-field__label"><span>申请对象</span></div>
        <div class="van-cell__value van-field__value">
          <span style="float:left;">
            <van-button
              round
              size="small"
              color="#3C9BFB"
              v-model="oneself_status"
              @click="show_oneself"
            >{{oneself}}</van-button>
          </span>
          <span @click="showDepartmentList">
            <i
              v-if="add_obj=='添加申请对象'"
              style="color:#c5c5c7"
            >{{add_obj}}</i><i v-else>{{add_obj}}</i>
            <i
              class="van-icon van-icon-arrow van-cell__right-icon"
              style="vertical-align:middle"
            ></i>
          </span>
        </div>
      </div>
    </div>
    <van-cell-group>
      <div style="height:10px;background:#f8f8f8"></div>
    </van-cell-group>
    <div
      class="van-cell-group van-hairline--top-bottom"
      @click="isShow"
    >
      <div class="van-cell van-cell--clickable van-field">
        <div class="van-cell__title van-field__label"><span>申请类型</span></div>
        <div class="van-cell__value van-field__value">
          <span class="left"> <i>{{radio_dd}}</i></span>
          <span>
            <i
              class="van-icon van-icon-arrow van-cell__right-icon"
              style="vertical-align:middle"
            ></i>
          </span>
        </div>
      </div>
    </div>
    <van-popup
      v-model="popup"
      round
      :safe-area-inset-bottom="true"
      :style="{width:'68%',fontSize:'14px'}"
      :overlay-style="{background:'rgba(0, 0, 0, 0.34)'}"
    >
      <div style="margin:15px 20px;">
        <van-radio-group v-model="radio">
          <van-radio
            :name="0"
            :style="{borderBottom:'0px',padding:'5px'}"
            @click="show_radio(0)"
          >奖分</van-radio>
          <van-radio
            :name="1"
            :style="{borderBottom:'0px',padding:'5px',marginTop:'5px'}"
            @click="show_radio(1)"
          >扣分</van-radio>
        </van-radio-group>
      </div>
    </van-popup>
    <van-cell-group v-if="ISC == 1">
      <van-field
        disabled
        center
        clearable
        :label="C_name+'/绩效'"
      >
        <van-switch
          v-if="is_c_code==1"
          slot="button"
          size="24px"
          active-color="#3C9BFB"
          v-model="checked"
          @click="show_C"
        />
        <van-switch
          v-else-if="is_c_code==0"
          disabled
          slot="button"
          size="24px"
          active-color="#3C9BFB"
          v-model="checked"
        />
      </van-field>
    </van-cell-group>
    <van-cell-group>
      <van-field
        v-if="val_D != ''"
        label="申请分数"
        type="digit"
        v-model="val_d"
        readonly
        :placeholder="val_tips_D"
      />
      <van-field
        v-else
        label="申请分数"
        type="digit"
        v-model="val_d"
        :placeholder="val_tips_D"
      />
    </van-cell-group>
    <van-cell-group>
      <van-field
        v-if="val_C !='' && is_c_code == 1"
        label=" "
        type="digit"
        readonly
        v-show="checked"
        v-model="val_c"
        :placeholder="val_tips_C"
      />
      <van-field
        v-else
        label=" "
        type="digit"
        v-show="checked"
        v-model="val_c"
        :placeholder="val_tips_C"
      />
    </van-cell-group>
    <van-cell-group>
      <van-field
        v-model="userListForm.end_time"
        label="申请时间"
        is-link
        disabled
        @click="endTime"
      />
      <van-popup
        v-model="endTimePop"
        round
        label="离开时间"
        :overlay="true"
        :style="{ width: '86%' }"
        :overlay-style="{background:'rgba(0, 0, 0, 0.44)'}"
      >
        <van-datetime-picker
          v-model="currentDate"
          type="date"
          :min-date="minDate"
          @cancel="endTimePop = false"
          @confirm="endTimePop = false"
          @change="endTimeChange"
        />
      </van-popup>
    </van-cell-group>
    <van-cell-group>
      <van-field
        disabled
        center
        clearable
        label="上传图片"
      >
        <van-uploader
          v-model="fileList"
          accept="image/png, image/jpeg,image/jpg"
          slot="input"
          multiple
          deletable
          :max-count="10"
          :before-read="beforeRead"
          :after-read="afterRead"
          :before-delete='beforDelete'
        />
      </van-field>
    </van-cell-group>
    <van-cell-group>
      <div style="height:5px;background:#f8f8f8"></div>
    </van-cell-group>
    <!-- 审核人 -->
    <div
      v-if="is_update_start==0"
      class="public"
      @click="show_Tips"
    >
      <div class="left_wrap">
        <span class="Left">初审人</span>
      </div>
      <div class="right_wrap">
        <span class="Right">{{obj.first_name}}</span>
      </div>
      <i class="van-icon van-icon-arrow van-cell__right-icon "></i>
    </div>
    <div
      v-else-if="is_update_start==1"
      class="public"
      @click="showPersonnel"
    >
      <div class="left_wrap">
        <span class="Left">初审人</span>
      </div>
      <div class="right_wrap">
        <span
          class="Right"
          v-if="list==undefined||list.length==0"
        >{{obj.first_name}}</span>
        <span
          class="Right"
          v-else
        >{{list.name}}</span>
      </div>
      <i class="van-icon van-icon-arrow van-cell__right-icon "></i>
    </div>
    <div
      v-if="is_update_end==0"
      class="public"
      @click="show_end_Tips"
    >
      <div class="left_wrap">
        <span class="Left">终审人</span>
      </div>
      <div class="right_wrap">
        <span class="Right">{{obj.end_name}}</span>
      </div>
      <i class="van-icon van-icon-arrow van-cell__right-icon "></i>
    </div>
    <div
      v-else-if="is_update_end==1"
      class="public"
      @click="showPersonnelList"
    >
      <div class="left_wrap">
        <span class="Left">终审人</span>
      </div>
      <div class="right_wrap">
        <span
          class="Right"
          v-if="arr==undefined||arr.length==0"
        >{{obj.end_name}}</span>
        <span class="Right">{{arr.name}}</span>
      </div>

      <i class="van-icon van-icon-arrow van-cell__right-icon "></i>
    </div>
    <van-button
      ref="refName"
      round
      :style="{width:'95%',height:'5.5vh',lineHeight:'5.5vh'}"
      color="#3C9BFB"
      @click="Submission"
    >提交</van-button>
    <van-overlay
      :show="isShowloading"
      @click="isShowloading = false"
    >
      <div
        class="wrapper"
        @click.stop
      >
        <van-loading
          vertical
          type="spinner"
          size="50"
        >图片上传中...</van-loading>
      </div>
    </van-overlay>
  </div>
</template>
<script type="text/javascript">
import {
  Cell,
  CellGroup,
  Popup,
  Field,
  Switch,
  Button,
  Uploader,
  DatetimePicker,
  Icon
} from "vant";
import {
  RadioGroup,
  Radio,
  Search,
  Tab,
  Tabs,
  Toast,
  Overlay,
  Loading
} from "vant";
import axios from "axios";
import depart from "@/components/departmentList";
export default {
  data() {
    return {
      isShowloading: false,
      depart_list_user: false,
      oneself_status: false,
      fileList: [],
      val_tips_D: "推荐分数: 5D分",
      val_tips_C: "推荐分数: 5C分",
      event_val: "",
      val_d: "",
      val_D: "",
      val_c: "",
      val_C: "",
      value_people_one: "",
      value_people_two: "",
      show_temporary_event: false,
      search_event: false,
      towEvent: false,
      threeEvent: false,
      fourEvent: false,
      see: false,
      radio: 0,
      popup: false,
      show: false,
      value_C: false,
      message: "",
      value: "",
      endTimePop: false,
      currentDate_end: "",
      userListForm: {},
      checked: false,
      minHour: 10,
      maxHour: 20,
      currentDate: new Date(),
      minDate: new Date(2016, 1, 1),
      maxDate: new Date(),
      active: "1",
      tabMain: [
        {
          name: "工作管理",
          index: 0
        },
        {
          name: "安全卫生",
          index: 0
        }
      ],
      cur: 0, //默认选中第一个tab
      list: [],
      arr: [],
      userlist_list: [],
      endlist: [],
      obj: {},
      event_list: [],
      two_list: [],
      three_list: [],
      four_list: [],
      one_Events: true,
      two_Events: true,
      three_Events: true,
      four_Events: true,
      two_event_id: 0,
      three_event_id: 0,
      four_event_id: 0,
      is_c_code: 0,
      same_review: 0,
      temp_event: 0,
      two_isInfo: 0,
      three_isInfo: 0,
      four_isInfo: 0,
      search_grade: 0,
      is_update_start: 1,
      is_update_end: 1,
      radio_dd: "奖分",
      isPlus: 0,
      event_Number: 0,
      event_val_id: 0,
      four_id: 0,
      oneName: "",
      towName: "",
      threeName: "",
      fourName: "",
      people_userId: 0,
      oneself: "添加本人",
      add_obj: "添加申请对象",
      C_name: "C分",
      D_name: "D分",
      list_string: [],
      user_id: 0,
      minD_D: 0,
      maxD_D: 0,
      minC_C: 0,
      maxC_C: 0,
      auto_submit: 0,
      base64_url: [],
      temp_event: 0,
      obj_event_name: {},
      sub_num: 0,
      open_num: 0,
      file_num: [],
      filesNum: [],
      is_loading_name: 0,
      is_update_user: "",
      first_user_name: "",
      one_name: "事件",
      two_name: "",
      three_name: "",
      four_name: "",
      ISC: ""
    };
  },
  components: {
    depart,
    [Popup.name]: Popup,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Field.name]: Field,
    [Switch.name]: Switch,
    [Button.name]: Button,
    [Uploader.name]: Uploader,
    [DatetimePicker.name]: DatetimePicker,
    [Icon.name]: Icon,
    [Search.name]: Search,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [Tab.name]: Tab,
    [Tabs.name]: Tabs,
    [Toast.name]: Toast,
    [Loading.name]: Loading,
    [Overlay.name]: Overlay
  },
  created() {
    this.getUserId();
    this.C_name = localStorage.getItem("c_name");
    this.D_name = localStorage.getItem("d_name");
    this.val_tips_D = "推荐分数: 5" + this.D_name;
    this.val_tips_C = "推荐分数: 5" + this.C_name;
    dd.biz.navigation.setTitle({
      title: "积分申请" //控制标题文本，空字符串表示显示默认文本
    });
  },

  methods: {
    // 钉钉鉴权
    async show_jsapi() {
      let corpId = localStorage.getItem("custid");
      // let corpId = this.$utils.getUrlKey("custid");
      let url = location.href.split("#")[0];
      const res = await this.$http.get(
        `dingapi/getJsapiConfig?corpId=${corpId}&url=${url}`
      );
      let config = res.data.data;
      localStorage.setItem("appId", config.agentId);
      dd.config({
        agentId: config.agentId,
        corpId: config.corpId,
        timeStamp: config.timeStamp,
        nonceStr: config.nonceStr,
        signature: config.signature,
        jsApiList: [
          "runtime.info",
          "biz.ding.post",
          "biz.ding.create",
          "biz.chat.pickConversation",
          "device.notification.prompt",
          "device.notification.confirm",
          "device.notification.alert",
          "biz.navigation.setRight",
          "biz.chat.open",
          "biz.util.open",
          "biz.util.openLink",
          "biz.user.get",
          "biz.contact.choose",
          "biz.telephone.call",
          "biz.util.uploadImage",
          // "device.accelerometer.watchShake",
          // "biz.map.locate",
          // "device.geolocation.get",
          "biz.customContact.choose",
          "biz.contact.complexPicker",
          "biz.contact.departmentsPicker"
        ]
      });
    },
    //C分开关
    async getIsC() {
      let corpId = localStorage.getItem("custid");
      const res = await this.$http.get(`yuepoints/getIsC?corpId=${corpId}`);
      // localStorage.setItem("ISC", res.data.data.is_c_code);
      this.ISC = res.data.data.is_c_code;
    },
    // 自定义名称存储
    async getCustomName() {
      // let corpId = this.$utils.getUrlKey("custid");
      let corpId = localStorage.getItem("custid");
      const res = await this.$http.get(
        `yuepoints/getCustomName?corpId=${corpId}`
      );
      if (res.data.errcode == "0000") {
        if (res.data.data.c_name == "") {
          localStorage.setItem("c_name", "C分");
        } else {
          localStorage.setItem("c_name", res.data.data.c_name);
        }
        if (res.data.data.d_name == "") {
          localStorage.setItem("d_name", "D分");
        } else {
          localStorage.setItem("d_name", res.data.data.d_name);
        }
      } else {
        localStorage.setItem("c_name", "C分");
        localStorage.setItem("d_name", "D分");
      }
    },
    // 获取用户信息
    async getUserId() {
      let Corp_Id = localStorage.getItem("custid");
      let User_Id = localStorage.getItem("userId");
      let corpId = this.$utils.getUrlKey("custid");
      if (corpId == null || corpId == "undefined") {
        corpId = Corp_Id;
      } else {
        localStorage.setItem("custid", corpId);
      }

      let code = "";
      var _this = this;
      if (User_Id && User_Id != "undefined" && User_Id != null) {
        if (Corp_Id != corpId) {
          await dd.runtime.permission.requestAuthCode({
            corpId: corpId,
            onSuccess: function(result) {
              code = result.code;
            },
            onFail: function(err) {}
          });
          _this.$http
            .get(`dingapi/signIn?corpId=${corpId}&code=${code}`)
            .then(res => {
              localStorage.setItem("userId", res.data.data.dd_id);
              localStorage.setItem("custid", corpId);
              _this.getCustomName();
              _this.show_trigger();
              _this.show_jsapi();
              _this.getIsC();
            });
        } else {
          _this.getCustomName();
          _this.show_trigger();
          _this.show_jsapi();
          _this.getIsC();
        }
      } else {
        await dd.runtime.permission.requestAuthCode({
          corpId: corpId,
          onSuccess: function(result) {
            code = result.code;
          },
          onFail: function(err) {}
        });
        _this.$http
          .get(`dingapi/signIn?corpId=${corpId}&code=${code}`)
          .then(res => {
            localStorage.setItem("userId", res.data.data.dd_id);
            localStorage.setItem("custid", corpId);
            _this.getCustomName();
            _this.show_trigger();
            _this.show_jsapi();
            _this.getIsC();
          });
      }
    },
    // 终审人提示
    show_end_Tips() {
      Toast("终审人不可更换");
    },
    // 初审人提示
    show_Tips() {
      Toast("初审人不可更换");
    },
    // 事件提交方式
    show_trigger() {
      if (this.$route.query.scan == 1 && this.$route.query.scan != undefined) {
        this.integralAttribute();
        this.showQR();
      } else {
        this.integralAttribute();
      }
    },
    // 二维码事件手动和自动提交数据展示 手动提交事件4  自动提交3
    async showQR() {
      let userId = localStorage.getItem("userId");
      let corpId = localStorage.getItem("custid");
      // let corpId = this.$utils.getUrlKey("custid");
      let qrId = this.$route.query.qrId;
      const res = await this.$http.get(
        `yuepoints/qrcode/event?corpId=${corpId}&userId=${userId}&qrId=${qrId}`
      );
      const {
        data: { auto_submit, event, userList, description, isPlus },
        errcode,
        errmsg
      } = res.data;
      let str = "";
      this.message = description;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let month, day;
      if (mm < 10) {
        month = "0" + mm;
      } else {
        month = mm;
      }
      if (dd < 10) {
        day = "0" + dd;
      } else {
        day = dd;
      }
      let date = yy + "-" + month + "-" + day;
      if (errcode == "0000") {
        this.auto_submit = auto_submit;
        // 自动提交分数
        if (auto_submit == 1) {
          let yy = new Date().getFullYear();
          let mm = new Date().getMonth() + 1;
          let dd = new Date().getDate();
          let month, day;
          if (mm < 10) {
            month = "0" + mm;
          } else {
            month = mm;
          }
          if (dd < 10) {
            day = "0" + dd;
          } else {
            day = dd;
          }
          let date = yy + "-" + month + "-" + day;
          this.userListForm.end_time = date;
          if (event.max_a != 0) {
            this.checked = true;
            this.val_c = event.max_a;
          }
          this.val_d = event.min_b;
          this.is_update_start = 0;
          this.is_update_end = 0;
        }
        if (event.isPlus == 0) {
          this.isPlus = 0;
          this.radio_dd = "奖分";
        } else {
          this.isPlus = 1;
          this.radio_dd = "扣分";
        }
        this.is_update_user = event.is_update_user;
        this.event_val = event.name;
        this.minD_D = event.min_b;
        this.maxD_D = event.max_b;
        this.minC_C = event.min_a;
        this.maxC_C = event.max_a;
        if (event.max_a == event.min_a) {
          this.val_c = event.min_a;
          this.val_C = event.min_a;
        } else {
          this.val_C = "";
          // console.log(this.val_C)
          this.val_tips_C =
            "推荐分数: " + this.C_name + event.min_a + "-" + event.max_a;
        }
        if (event.max_b == event.min_b) {
          this.val_d = event.min_b;
          this.val_D = event.min_b;
        } else {
          this.val_D = "";
          // console.log(this.val_D)
          this.val_tips_D =
            "推荐分数: " + this.D_name + event.min_b + "-" + event.max_b;
        }
        for (let i = 0; i < userList.length; i++) {
          if (userList[i].empl_id == userId) {
            this.oneself = "已添加本人";
            str = userList[i].empl_id;
          } else {
            str += `${userList[i].empl_id},`;
          }
        }
        this.user_id = str;
        // 父级事件
        let parent_event = event.parents;
        for (let j = 0; j < parent_event.length; j++) {
          if (parent_event[j].level == 1) {
            this.two_event_id = parent_event[j].event_id;
            this.oneName = parent_event[j].event_name;
            this.three_event_id = event.id;
            this.twoName = event.name;
          }
          if (parent_event[j].level == 2) {
            this.three_event_id = parent_event[j].event_id;
            this.twoName = parent_event[j].event_name;
            this.four_event_id = event.id;
            this.threeName = event.name;
          }
          if (parent_event[j].level == 3) {
            this.four_event_id = parent_event[j].event_id;
            this.threeName = parent_event[j].event_name;
            this.four_id = event.id;
            this.fourName = event.name;
          }
        }
        // 申请对象
        if (userList.length == 1) {
          this.add_obj = userList[0].name;
        } else {
          this.add_obj = userList[0].name + "等" + userList.length + "人";
        }
        if (Number(auto_submit) == 1) {
          // 初审人
          if (event.fixed_first_user != ""&&event.fixed_first_name != "系统") {
            this.obj.first_name = event.fixed_first_name;
            this.obj.first_id = event.fixed_first_user;
          } else if(event.fixed_first_name == "系统"){         
            this.obj.first_name = event.fixed_first_name;
            this.obj.first_id = "";
          }
          if (event.is_update_user == 0 && event.fixed_first_user != ""&&event.fixed_first_user != "系统") {
            this.list.emplId = event.fixed_first_user;
          }else if(event.fixed_first_user == "系统"){
           this.list.emplId = "";
          }
          if (event.is_update_user == 0 && event.fixed_end_user != "") {
            this.arr.emplId = event.fixed_end_user;
          }
          // 终审人
          if (event.fixed_end_user != "") {
            this.obj.end_name = event.fixed_end_name;
            this.obj.end_id = event.fixed_end_user;
          } else {
            this.obj.end_name = "请选择";
            this.obj.end_id = "";
          }
        }
        if (Number(auto_submit) == 0) {
          this.userListForm.end_time = date;
          if (event.fixed_first_user != "") {
            this.obj.first_name = event.fixed_first_name;
            this.obj.first_id = event.fixed_first_user;
          } else if (
            Number(event.is_update_user) == 0 &&
            event.fixed_first_name == "系统"
          ) {
            this.is_update_start = 0;
            this.obj.first_name = event.fixed_first_name;
            this.obj.first_id = "";
          } else {
            this.is_update_start = 1;
            this.obj.first_name = "请选择";
          }
          // 终审人
          if (event.fixed_end_user != "") {
            this.obj.end_name = event.fixed_end_name;
            this.obj.end_id = event.fixed_end_user;
          } else if (
            Number(event.is_update_user) == 0 &&
            event.fixed_end_name == "系统"
          ) {
            this.is_update_end = 0;
            this.obj.end_name = event.fixed_end_name;
            this.obj.end_id = "";
          } else {
            this.is_update_end = 1;
            this.obj.end_name = "请选择";
          }
          if (
            event.is_update_user == 0 &&
            event.fixed_first_user != "" &&
            event.fixed_first_user != "系统"
          ) {
            this.list.emplId = event.fixed_first_user;
          } else {
            this.list.emplId = "";
          }
          if (
            event.is_update_user == 0 &&
            event.fixed_end_user != "" &&
            event.fixed_end_user != "系统"
          ) {
            this.arr.emplId = event.fixed_end_user;
          } else {
            this.arr.emplId = "";
          }
        }
        if (Number(auto_submit) == 1) {
          Toast.loading({
            message: "提交中",
            forbidClick: true,
            loadingType: "spinner"
          });
          this.$refs.refName.click();
        }
      } else {
        this.$toast(errmsg);
      }
    },
    // 删除附件
    async beforDelete(file) {
      let tmp = this.fileList;
      for (let i = 0; i < tmp.length + 1; i++) {
        if (tmp[i].url === file.url) {
          tmp.splice(i, 1);
          this.fileList.splice(i, 1);
          this.filesNum.splice(i, 1);
          this.file_num.splice(i, 1);
          let obj_name;
          let corpId = localStorage.getItem("custid");
          obj_name = {
            corpId: corpId,
            url: file.url
          };
          var qs = require("qs");
          var instance = axios.create({
            headers: { "content-type": "application/x-www-form-urlencoded" }
          });
          const res = await instance.post(
            "https://upperinterface.changyuelife.com/dingAPI/deleteImage",
            qs.stringify(obj_name)
          );
          if (res.data.code != "0000") {
            this.$toast(res.data.message);
          }
          return false;
        }
      }
    },
    // 上传事件
    async afterRead(file) {
      this.isShowloading = true;
      let corpId = localStorage.getItem("custid");
      var qs = require("qs");
      var instance = axios.create({
        headers: { "content-type": "application/x-www-form-urlencoded" }
      });
      let _this = this;
      if (file.length > 1) {
        this.fileList = [];
        let q = 0;
        for (let i = 0; i < file.length; ++i) {
          let obj_name = {
            corpId: corpId,
            base64: file[i].content
          };
          await instance
            .post(
              "https://upperinterface.changyuelife.com/dingAPI/upload",
              qs.stringify(obj_name)
            )
            .then(res => {
              if (res.data.code == "0000") {
                q++;
                _this.filesNum.push({ url: res.data.url });
              } else {
                _this.$toast("上传图片失败");
              }
            });
        }
        if (this.file_num.length > 1) {
          this.fileList = this.filesNum.concat(this.file_num);
        } else {
          this.fileList = this.filesNum;
        }
        if (this.is_loading_name == q) {
          this.isShowloading = false;
        }
      } else {
        this.fileList = [];
        let obj_name = {
          corpId: corpId,
          base64: file.content
        };
        await instance
          .post(
            "https://upperinterface.changyuelife.com/dingAPI/upload",
            qs.stringify(obj_name)
          )
          .then(res => {
            if (res.data.code == "0000") {
              // Toast.success("图片上传成功");
              _this.isShowloading = false;
              _this.file_num.push({ url: res.data.url });
              _this.fileList = _this.file_num;
            } else {
              _this.$toast("上传图片失败");
            }
          });
        if (this.filesNum.length > 1) {
          this.fileList = this.filesNum.concat(this.file_num);
        }
      }
    },
    // 附件校验
    beforeRead(file) {
      if (file.size > 5 * 1024 * 1024) {
        Toast("上传文件大小不得超过3M");
        return false;
      }
      if (file.length > 1) {
        this.is_loading_name = file.length;
        for (let i = 0; i < file.length; i++) {
          if (file[i].size > 5 * 1024 * 1024) {
            this.$toast("上传文件大小不得超过3M");
            return false;
          }
        }
      }
      return true;
    },
    // 添加本人
    async show_oneself() {
      this.oneself_status = !this.oneself_status;
      this.oneself = "已添加本人";
      let userId = localStorage.getItem("userId");
      let corpId = localStorage.getItem("custid");
      // let corpId = this.$utils.getUrlKey("custid");
      const res = await this.$http.get(
        `yuepoints/getUserInfo?corpId=${corpId}&userId=${userId}`
      );
      const { data } = res.data;
      this.add_obj = data.name;
      if (this.oneself_status == false) {
        this.oneself = "添加本人";
        this.add_obj = "添加申请对象";
      } else if (this.oneself_status == true) {
        this.oneself = "已添加本人";
        this.user_id = userId;
      }
    },

    // 奖扣分
    show_radio(i) {
      this.popup = false;
      if (i == 0) {
        this.radio_dd = "奖分";
        this.isPlus = 0;
      } else {
        this.radio_dd = "扣分";
        this.isPlus = 1;
      }
    },
    // 临时事件
    show_temporary_click() {
      if (this.temp_event_num == 0) {
        this.$toast("临时事件无法提交");
        this.temp_event = 0;
      } else {
        this.val_D = '';
        this.val_C = '';
        this.show = false;
        this.event_val = this.value;
        this.temp_event = 1;
        this.val_tips_D = "推荐分数: " + this.D_name + "0- 100";
        this.val_tips_C = "推荐分数: " + this.C_name + "0 - 100";
      }
    },
    // 搜索事件
    async onSearch() {
      if (this.search_grade == 0) {
        this.oneName = this.oneName;
        this.showTowEvent(this.oneName, this.two_event_id, this.value);
      } else if (this.search_grade == 1) {
        this.showThreeEvent(this.twoName, this.three_event_id, this.value);
      } else if (this.search_grade == 2) {
        this.showFourEvent(this.threeName, this.four_event_id, this.value);
      }else if(this.search_grade == 6){
        this.getEvent(this.value)
      }
    },
    // 搜索事件取消
    onCancel() {
      this.show_event_name_one()
    },
    // 事件标题点击事件
    show_event_name_three(item) {
      this.three_list = item;
      this.two_list = item;
      this.one_Events = false;
      this.two_Events = false;
      this.three_Events = true;
      this.four_Events = false;
      this.towEvent = true;
      this.threeEvent = true;
      this.fourEvent = false;
    },
    show_event_name_two() {
      const id = this.two_event_id;
      this.showTowEvent(this.oneName, id);
      this.three_Events = false;
      this.four_Events = false;
      this.threeEvent = false;
      this.fourEvent = false;
    },
    show_event_name_one() {
      this.getEvent();
      this.show_temporary_event = false;
      this.one_Events = true;
      this.two_Events = false;
      this.three_Events = false;
      this.four_Events = false;
      this.towEvent = false;
      this.threeEvent = false;
      this.fourEvent = false;
      this.search_event = true;
    },
    // 事件点击事件
    async show_four_event(ul, it, name) {
      let corpId = localStorage.getItem("custid");
      this.four_name = ul;
      this.search_grade = 3;
      this.val_d = "";
      this.val_c = "";
      if (name == undefined) {
        name = "";
      }
      const res = await this.$http.get(
        `yuepoints/Event?corpId=${corpId}&type=0&parent=${it}&name=${name}`
      );
      if (res.data.isInfo == 1) {
        const {
          id,
          fixed_first_user,
          fixed_end_user,
          first_user_name,
          end_user_name,
          is_update_user,
          name,
          level,
          minc,
          maxc,
          mind,
          maxd,
          isPlus
        } = res.data.data;
        this.event_val = name;
        this.event_val_id = id;
        this.show = false;
        this.minD_D = mind;
        this.maxD_D = maxd;
        this.minC_C = minc;
        this.maxC_C = maxc;
        this.is_update_user = is_update_user;
        this.first_user_name = first_user_name;
        let checker_obj = JSON.parse(localStorage.getItem("checker"));
        this.val_tips_D = "推荐分数: " + this.D_name + mind + " - " + maxd;
        this.val_tips_C = "推荐分数: " + this.C_name + minc + " - " + maxc;
        if (mind === maxd) {
          this.val_D = mind;
          this.val_d = maxd;
        } else {
          this.val_D = "";
        }
        if (minc === maxc) {
          this.val_C = minc;
          this.val_c = maxc;
        } else {
          this.val_C = "";
        }
        if (!this.isEmpty(fixed_first_user) || first_user_name == "系统") {
          this.is_update_start = is_update_user;
          if (is_update_user == 0) {
            this.list.emplId = fixed_first_user;
          } else if (is_update_user == 1 && first_user_name == "系统") {
            this.list.emplId = fixed_first_user;
          } else {
            this.obj.first_id = fixed_first_user;
          }
          // this.is_update_start = 0;
          this.obj.first_name = first_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.first_name = first_user_name;
            this.list.emplId = fixed_first_user;
            this.is_update_start = 1;
          } else {
            this.obj.first_name = checker_obj.first_name;
            this.list.emplId = checker_obj.first_id;
            this.is_update_start = 1;
          }
        }
        if (!this.isEmpty(fixed_end_user)) {
          this.is_update_end = is_update_user;
          if (is_update_user == 0) {
            this.arr.emplId = fixed_end_user;
          } else {
            this.obj.end_id = fixed_end_user;
          }
          this.obj.end_name = end_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.end_name = end_user_name;
            this.arr.emplId = fixed_end_user;
            this.is_update_end = 1;
          } else {
            this.obj.end_name = checker_obj.end_name;
            this.arr.emplId = checker_obj.end_id;
            this.is_update_end = 1;
          }
        }
        if (isPlus == 0) {
          this.isPlus = 0;
          this.radio_dd = "奖分";
        } else {
          this.isPlus = 1;
          this.radio_dd = "扣分";
        }
        this.fourName = name;
        this.four_id = id;
        this.event_val = name;
        this.event_val_id = id;
        this.show = false;
      } else {
        this.fourName = ul;
        this.four_id = it;
        this.event_val = ul;
        this.event_val_id = it;
        this.show = false;
      }
    },
    async showFourEvent(ul, it, name) {
      let corpId = localStorage.getItem("custid");
      this.threeName = ul;
      this.three_name = ul;
      this.four_name = "";
      this.four_event_id = it;
      this.search_grade = 2;
      this.val_d = "";
      this.val_c = "";
      if (name == undefined) {
        name = "";
      }
      const res = await this.$http.get(
        `yuepoints/Event?corpId=${corpId}&type=0&parent=${it}&name=${name}`
      );
      this.four_list = res.data.data;
      this.four_isInfo = res.data.isInfo;
      if (res.data.isInfo == 1) {
        const {
          id,
          fixed_first_user,
          fixed_end_user,
          first_user_name,
          end_user_name,
          is_update_user,
          name,
          level,
          minc,
          maxc,
          mind,
          maxd,
          isPlus
        } = res.data.data;
        this.event_val = name;
        this.event_val_id = id;
        this.show = false;
        this.minD_D = mind;
        this.maxD_D = maxd;
        this.minC_C = minc;
        this.maxC_C = maxc;
        let checker_obj = JSON.parse(localStorage.getItem("checker"));
        this.val_tips_D = "推荐分数: " + this.D_name + mind + " - " + maxd;
        this.val_tips_C = "推荐分数: " + this.C_name + minc + " - " + maxc;
        if (mind === maxd) {
          this.val_D = mind;
          this.val_d = maxd;
        } else {
          this.val_D = "";
        }
        if (minc === maxc) {
          this.val_C = minc;
          this.val_c = maxc;
        } else {
          this.val_C = "";
        }
        this.is_update_user = is_update_user;
        this.first_user_name = first_user_name;
        if (!this.isEmpty(fixed_first_user) || first_user_name == "系统") {
          this.is_update_start = is_update_user;
          if (is_update_user == 0) {
            this.list.emplId = fixed_first_user;
          } else if (is_update_user == 1 && first_user_name == "系统") {
            this.list.emplId = fixed_first_user;
          } else {
            this.obj.first_id = fixed_first_user;
          }
          // this.is_update_start = 0;
          this.obj.first_name = first_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.first_name = first_user_name;
            this.list.emplId = fixed_first_user;
            this.is_update_start = 1;
          } else {
            this.obj.first_name = checker_obj.first_name;
            this.list.emplId = checker_obj.first_id;
            this.is_update_start = 1;
          }
        }
        if (!this.isEmpty(fixed_end_user)) {
          this.is_update_end = is_update_user;
          if (is_update_user == 0) {
            this.arr.emplId = fixed_end_user;
          } else {
            this.obj.end_id = fixed_end_user;
          }
          this.obj.end_name = end_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.end_name = end_user_name;
            this.arr.emplId = fixed_end_user;
            this.is_update_end = 1;
          } else {
            this.obj.end_name = checker_obj.end_name;
            this.arr.emplId = checker_obj.end_id;
            this.is_update_end = 1;
          }
        }
        if (isPlus == 0) {
          this.isPlus = 0;
          this.radio_dd = "奖分";
        } else {
          this.isPlus = 1;
          this.radio_dd = "扣分";
        }
      } else {
        this.fourEvent = true;
        this.four_Events = true;
        this.three_Events = false;
      }
      if (res.data.errcode == "1005") {
        this.show_temporary_event = true;
        this.event_Number = 4;
        this.threeName = ul;
        this.is_update_start = 1;
        this.is_update_end = 1;
      }else{
         this.event_Number = 0;
      }
    },
    async showThreeEvent(ol, it, name) {
      let corpId = localStorage.getItem("custid");
      this.twoName = ol;
      this.two_name = ol;
      this.three_name = "";
      this.four_name = "";
      this.search_grade = 1;
      this.val_d = "";
      this.val_c = "";
      if (name == undefined) {
        name = "";
      }
      this.three_event_id = it;
      const res = await this.$http.get(
        `yuepoints/Event?corpId=${corpId}&type=0&parent=${it}&name=${name}`
      );
      this.three_list = res.data.data;
      this.three_isInfo = res.data.isInfo;
      if (res.data.isInfo == 1) {
        const {
          id,
          fixed_first_user,
          fixed_end_user,
          first_user_name,
          end_user_name,
          is_update_user,
          name,
          level,
          minc,
          maxc,
          mind,
          maxd,
          isPlus
        } = res.data.data;
        if (isPlus == 0) {
          this.radio_dd = "奖分";
          this.isPlus = 0;
        } else {
          this.radio_dd = "扣分";
          this.isPlus = 1;
        }
        this.event_val = name;
        this.event_val_id = id;
        this.show = false;
        this.minD_D = mind;
        this.maxD_D = maxd;
        this.minC_C = minc;
        this.maxC_C = maxc;
        let checker_obj = JSON.parse(localStorage.getItem("checker"));
        this.val_tips_D = "推荐分数: " + this.D_name + mind + " - " + maxd;
        this.val_tips_C = "推荐分数: " + this.C_name + minc + " - " + maxc;
        if (mind === maxd) {
          this.val_D = mind;
          this.val_d = maxd;
        } else {
          this.val_D = "";
        }
        if (minc === maxc) {
          this.val_C = minc;
          this.val_c = maxc;
        } else {
          this.val_C = "";
        }
        this.is_update_user = is_update_user;
        this.first_user_name = first_user_name;
        if (!this.isEmpty(fixed_first_user) || this.first_user_name == "系统") {
          this.is_update_start = is_update_user;
          if (is_update_user == 0) {
            this.list.emplId = fixed_first_user;
          } else if (is_update_user == 1 && first_user_name == "系统") {
            this.list.emplId = fixed_first_user;
          } else {
            this.obj.first_id = fixed_first_user;
          }
          // this.is_update_start = 0;
          this.obj.first_name = first_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.first_name = first_user_name;
            this.list.emplId = fixed_first_user;
            this.is_update_start = 1;
          } else {
            this.obj.first_name = checker_obj.first_name;
            this.list.emplId = checker_obj.first_id;
            this.is_update_start = 1;
          }
        }
        if (!this.isEmpty(fixed_end_user)) {
          this.is_update_end = is_update_user;
          if (is_update_user == 0) {
            this.arr.emplId = fixed_end_user;
          } else {
            this.obj.end_id = fixed_end_user;
          }
          this.obj.end_name = end_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.end_name = end_user_name;
            this.arr.emplId = fixed_end_user;
            this.is_update_end = 1;
          } else {
            this.obj.end_name = checker_obj.end_name;
            this.arr.emplId = checker_obj.end_id;
            this.is_update_end = 1;
          }
        }
      } else {
        this.threeEvent = true;
        this.two_Events = false;
        this.three_Events = true;
      }
      if (res.data.errcode == "1005") {
        this.show_temporary_event = true;
        this.event_Number = 3;
        this.twoName = ol;
        this.is_update_start = 1;
        this.is_update_end = 1;
      }else{
         this.event_Number = 0;
      }
    },
    async getEvent(name) {
      let corpId = localStorage.getItem("custid");
       if (name == undefined) {
        name = "";
      }
      const res = await this.$http.get(
        `yuepoints/Event?corpId=${corpId}&type=0&parent=0&name=${name}`
      );
      if(res.data.errcode=='1005'){
        this.one_name='无此事件';
        this.event_list =[]
      }else{
        this.one_name='事件';
        this.event_list = res.data.data;
      }
    },
    async showTowEvent(ll, id, name) {
      this.one_name = ll;
      let corpId = localStorage.getItem("custid");
      this.oneName = ll;
      this.two_name = "";
      this.three_name = "";
      this.four_name = "";
      this.search_grade = 0;
      this.val_d = "";
      this.val_c = "";
      if (name == undefined) {
        name = "";
      }
      this.two_event_id = id;
      const res = await this.$http.get(
        `yuepoints/Event?corpId=${corpId}&type=0&parent=${id}&name=${name}`
      );
      this.two_list = res.data.data;
      this.two_isInfo = res.data.isInfo;
      if (res.data.isInfo == 1) {
        const {
          id,
          fixed_first_user,
          fixed_end_user,
          first_user_name,
          end_user_name,
          is_update_user,
          name,
          level,
          minc,
          maxc,
          mind,
          maxd,
          isPlus
        } = res.data.data;
        if (isPlus == 0) {
          this.radio_dd = "奖分";
          this.isPlus = 0;
        } else {
          this.radio_dd = "扣分";
          this.isPlus = 1;
        }
        this.event_val = name;
        this.event_val_id = id;
        this.show = false;
        this.minD_D = mind;
        this.maxD_D = maxd;
        this.minC_C = minc;
        this.maxC_C = maxc;
        let checker_obj = JSON.parse(localStorage.getItem("checker"));
        this.val_tips_D = "推荐分数: " + this.D_name + mind + " - " + maxd;
        this.val_tips_C = "推荐分数: " + this.C_name + minc + " - " + maxc;
        if (mind === maxd) {
          this.val_D = mind;
          this.val_d = maxd;
        } else {
          this.val_D = "";
        }
        if (minc === maxc) {
          this.val_C = minc;
          this.val_c = maxc;
        } else {
          this.val_C = "";
        }
        this.is_update_user = is_update_user;
        this.first_user_name = first_user_name;
        if (!this.isEmpty(fixed_first_user) || first_user_name == "系统") {
          this.is_update_start = is_update_user;
          if (is_update_user == 0) {
            this.list.emplId = fixed_first_user;
          } else if (is_update_user == 1 && fixed_user_name == "系统") {
            this.list.emplId = fixed_end_user;
          } else {
            this.obj.first_id = fixed_first_user;
          }
          // this.is_update_start = 0;
          this.obj.first_name = first_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.first_name = first_user_name;
            this.list.emplId = fixed_first_user;
            this.is_update_start = 1;
          } else {
            this.obj.first_name = checker_obj.first_name;
            this.list.emplId = checker_obj.first_id;
            this.is_update_start = 1;
          }
        }
        if (!this.isEmpty(fixed_end_user)) {
          this.is_update_end = is_update_user;
          if (is_update_user == 0) {
            this.arr.emplId = fixed_end_user;
          } else {
            this.obj.end_id = fixed_end_user;
          }
          this.obj.end_name = end_user_name;
        } else {
          if (checker_obj == null) {
            this.obj.end_name = end_user_name;
            this.arr.emplId = fixed_end_user;
            this.is_update_end = 1;
          } else {
            this.obj.end_name = checker_obj.end_name;
            this.arr.emplId = checker_obj.end_id;
            this.is_update_end = 1;
          }
        }
      } else {
        this.search_event = true;
        this.one_Events = false;
        this.towEvent = true;
        this.two_Events = true;
      }
      if (res.data.errcode == "1005") {
        this.show_temporary_event = true;
        this.event_Number = 2;
        this.oneName = ll;
        this.is_update_start = 1;
        this.is_update_end = 1;
      }else{
         this.event_Number = 0;
      }
    },
    // 数据默认展示
    async integralAttribute() {
      let corpId = localStorage.getItem("custid");
      let userId = localStorage.getItem("userId");
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let month, day;
      if (mm < 10) {
        month = "0" + mm;
      } else {
        month = mm;
      }
      if (dd < 10) {
        day = "0" + dd;
      } else {
        day = dd;
      }
      let year = yy + "-" + month + "-" + day;
      this.userListForm.end_time = year;
      const res = await this.$http.get(
        `yuepoints/integralAttribute?corpId=${corpId}&userId=${userId}`
      );
      const { Auditor, is_c_code, same_review, temp_event } = res.data.data;
      this.is_c_code = is_c_code;
      this.same_review = same_review;
      this.temp_event_num = temp_event;
      localStorage.setItem("checker", JSON.stringify(Auditor));
      if (!this.isEmpty(Auditor)) {
        this.obj = Auditor;
        this.list.emplId = Auditor.first_id;
        this.arr.emplId = Auditor.end_id;
      } else {
        this.list = { name: "请选择" };
        this.arr = { name: "请选择" };
      }
    },
    // 判断是否为空
    isEmpty(obj) {
      if (typeof obj == "undefined" || obj == null || obj == "") {
        return true;
      } else {
        return false;
      }
    },
    // 开关
    show_C() {
      this.checked = !this.checked;
    },
    // 申请对象
    showDepartmentList() {
      let corpId = localStorage.getItem("custid");
      let appId = localStorage.getItem("appId");
      let _this = this;
      dd.biz.contact.complexPicker({
        title: "申请对象", //标题
        corpId: corpId, //企业的corpId
        multiple: true, //是否多选
        limitTips: "最多选择20人", //超过限定人数返回提示
        maxUsers: 20, //最大可选人数
        pickedUsers: [], //已选用户
        pickedDepartments: [], //已选部门
        disabledUsers: [], //不可选用户
        disabledDepartments: [], //不可选部门
        requiredUsers: [], //必选用户（不可取消选中状态）
        requiredDepartments: [], //必选部门（不可取消选中状态）
        appId: appId, //微应用的Id
        permissionType: "GLOBAL", //选人权限，目前只有GLOBAL这个参数
        responseUserOnly: true, //返回人，或者返回人和部门
        startWithDepartmentId: 0, // 0表示从企业最上层开始
        onSuccess: function(result) {
          _this.list_string = result.users;
          _this.add_obj =
            result.users[0].name + "等" + result.selectedCount + "人";
        },
        onFail: function(err) {}
      });
    },
    //初审人
    async showPersonnel() {
      let corpId = localStorage.getItem("custid");
      let appId = localStorage.getItem("appId");
      let userId = localStorage.getItem("userId");
      let _this = this;
      const res = await this.$http.get(
        `yuepoints/getReviewer?corpId=${corpId}&userId=${userId}&type=1`
      );
      this.userlist_list = res.data.data.first;
      let users = [];

      for (var i = 0; i < this.userlist_list.length; i++) {
        users.push(this.userlist_list[i].dd_id);
      }
      dd.biz.customContact.choose({
        title: "初审人", //标题
        users: users, //一组员工userid
        corpId: corpId, //加密的企业 ID，
        isShowCompanyName: true, //true|false，默认为 false
        // disabledUsers: ["78308"], //不能选的人
        onSuccess: function(data) {
          _this.obj.first_name = data[0].name;
          _this.list = data[0];
        },
        onFail: function(err) {}
      });
    },
    //终审人
    async showPersonnelList() {
      let corpId = localStorage.getItem("custid");
      let appId = localStorage.getItem("appId");
      let userId = localStorage.getItem("userId");
      let _this = this;
      const res = await this.$http.get(
        `yuepoints/getReviewer?corpId=${corpId}&userId=${userId}&type=2`
      );
      this.endlist = res.data.data.end;
      let users = [];
      for (var i = 0; i < this.endlist.length; i++) {
        users.push(this.endlist[i].dd_id);
      }
      dd.biz.customContact.choose({
        title: "终审人", //标题
        users: users, //一组员工userid
        corpId: corpId, //加密的企业 ID，
        isShowCompanyName: true, //true|false，默认为 false
        // disabledUsers: ["78308"], //不能选的人
        onSuccess: function(data) {
          _this.obj.end_name = data[0].name;
          _this.arr = data[0];
        },
        onFail: function(err) {}
      });
    },
    // 时间弹框
    endTime() {
      this.endTimePop = true;
    },
    // 申请事件弹框显示
    async showPopup() {
      this.search_grade = 6;
      this.two_event_id = 0;
      this.oneName = "";
      this.three_event_id = 0;
      this.four_event_id = 0;
      this.four_id = 0;
      this.twoName = "";
      this.threeName = "";
      this.fourName = "";
      this.one_name='事件'
      this.show = true;
      this.show_event_name_one();
      this.show_temporary_event = false;
      this.value = "";
    },
    // 申请类型弹框显示
    isShow() {
      this.popup = true;
    },
    // 时间选择
    endTimeChange(e) {
      let endTimeArr = e.getValues(); //["2019", "03", "22", "17", "28"]
      this.userListForm.end_time = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`;
    },
    // 提交
    async Submission() {
      if (this.event_val == "") {
        this.$toast("请选择事件名称");
        return;
      }
      let userList_string = "";
      if (this.list_string.length == 0) {
        userList_string = this.user_id;
        if (this.user_id == 0) {
          this.$toast("请选择奖扣人");
          return;
        }
      } else {
        for (let f = 0; f < this.list_string.length; f++) {
          userList_string += `${this.list_string[f].emplId},`;
        }
      }
      let maxD, minD, maxC, minC;
      if (this.val_d == "") {
        this.$toast(this.D_name + "不能为空");
        return;
      } else {
        maxD = Number(this.maxD_D);
        minD = Number(this.minD_D);
        maxC = Number(this.maxC_C);
        minC = Number(this.minC_C);
      }
      const desc = this.message;
      let codeD, codeC;
      if (this.val_d <= maxD && this.val_d >= minD && this.temp_event != 1) {
        codeD = this.val_d;
      } else if (this.val_tips_D.indexOf("-") > -1 && this.temp_event != 1) {
        this.$toast("请在推荐范围中填写");
        return;
      } else {
        codeD = this.val_d;
      }

      if (this.is_c_code == 1 && this.val_c != "" && this.temp_event != 1) {
        if (this.val_c <= maxC && this.val_c >= minC && this.temp_event != 1) {
          codeC = this.val_c;
        } else {
          this.$toast("请在推荐范围中填写");
          return;
        }
      } else {
        codeC = this.val_c;
      }
      if (this.checked == true && this.val_c == "") {
        this.$toast("请填写" + this.C_name);
        return;
      }
      let first, end;
      if (this.is_update_user == 1 && this.same_review == 0) {
        if (this.arr == undefined || this.arr.length == 0) {
          end = this.obj.end_id;
        } else {
          end = this.arr.emplId;
        }
        if (this.first_user_name == "系统") {
          first = this.list.emplId;
        } else if (this.list == undefined || this.list.length == 0) {
          first = this.obj.first_id;
        } else {
          first = this.list.emplId;
        }
      } else if (this.is_update_user == 1 && this.same_review == 1) {
        if (this.arr == undefined || this.arr.length == 0) {
          end = this.obj.end_id;
        } else {
          end = this.arr.emplId;
        }
        if (this.first_user_name == "系统") {
          first = this.list.emplId;
        } else if (this.list == undefined || this.list.length == 0) {
          first = this.obj.first_id;
        } else {
          first = this.list.emplId;
        }
      } else {
        first = this.list.emplId;
        end = this.arr.emplId;
      }
      let tempLevel = this.event_Number;
      const isPlus = this.isPlus;
      const date = this.userListForm.end_time;
      let temporary,
        one,
        two,
        three,
        four,
        oneName,
        twoName,
        threeName,
        fourName;
      if (tempLevel < 2) {
        tempLevel = "";
        temporary = 0;
        two = this.three_event_id;
        three = this.four_event_id;
        four = this.four_id;
        twoName = this.twoName;
        threeName = this.threeName;
        fourName = this.fourName;
      } else {
        temporary = 1;
        if (tempLevel == 2) {
          twoName = this.value;
          two = 0;
        } else {
          two = this.three_event_id;
          twoName = this.twoName;
        }
        if (tempLevel == 3) {
          threeName = this.value;
          three = 0;
        } else {
          three = this.four_event_id;
          threeName = this.threeName;
        }
        if (tempLevel == 4) {
          fourName = this.value;
          four = 0;
        } else {
          four = this.four_id;
          fourName = this.fourName;
        }
      }
      one = this.two_event_id;
      oneName = this.oneName;
      // console.log(this.checked)
      if (this.checked == false) {
        codeC = "";
      }
      let corpId = localStorage.getItem("custid");
      let userId = localStorage.getItem("userId");
      let obj_name = {
        corpId: corpId,
        userId: userId,
        desc: desc,
        codeD: codeD,
        first: first,
        end: end,
        codeC: codeC,
        isPlus: isPlus,
        date: date,
        tempLevel: tempLevel,
        temporary: temporary,
        userList: userList_string,
        one: one,
        two: two,
        three: three,
        four: four,
        oneName: oneName,
        twoName: twoName,
        threeName: threeName,
        fourName: fourName,
        picturefile: this.fileList
      };
      console.log(obj_name)
      this.sub_num = this.sub_num + 1;
      if (this.sub_num > 1) {
        Toast("请勿重复提交");
        return;
      }
      if (this.auto_submit != 1) {
        Toast.loading({
          message: "提交中",
          forbidClick: true,
          loadingType: "spinner"
        });
      }
      var qs = require("qs");
      var instance = axios.create({
        headers: { "content-type": "application/x-www-form-urlencoded" }
      });
      let _this = this;
      const res = await instance
        .post("yuepoints/integralApplication", qs.stringify(obj_name))
        .then(function(res) {
          const { errcode, errmsg } = res.data;
          if (errcode != "0000") {
            Toast.fail("提交失败");
            _this.sub_num = 0;
            if (_this.auto_submit == 1) {
              Toast.loading({
                message: "提交中",
                forbidClick: true,
                loadingType: "spinner"
              });
            }
            Toast(errmsg);
          }
          if (errcode == "0000") {
            Toast.success("提交成功");
            _this.sub_num = 0;
            if (_this.auto_submit == 1) {
              Toast.success("处理成功");
            }
            _this.$router.replace("/home");
          }
        })
        .catch(function(error) {
          _this.sub_num = 0;
        });
    }
  }
};
</script>

<style lang='less' scoped>
.box {
  padding-bottom: 15px;
}
/deep/ .van-field__control:disabled {
  color: #323233;
  -webkit-appearance: none;
  // -webkit-text-fill-color:#323233;
  // opacity: 0.5;
}
i {
  font-style: normal;
}
.temporary {
  font-size: 14px;
  background: #2196f3;
  margin: 0px 30px 5px;
  height: 30px;
  line-height: 30px;
  color: #fff;
}
/deep/ .van-cell--clickable:active {
  background: #ffff !important;
}
/deep/ .van-radio {
  background: #fff;
  border-bottom: 1px solid #e6e3e3;
  padding: 5px 10px;
}
dl {
  margin: 0px;
  font-size: 15px;
  margin-left: 17px;
  dt {
    font-weight: 700;
    text-align: left;
    height: 20px;
    margin-bottom: 10px;
  }
  dd {
    margin: 0px;
    font-size: 14px;
    text-align: left;
  }
}
.hide {
  display: none;
}
.tab-lists {
  li {
    text-align: left;
    font-size: 14px;
  }
}
.tab-title {
  width: 100%;
  padding-left: 10px;
  font-size: 15px;
  list-style: none;
  display: inline-block;
  li {
    float: left;
    width: 24%;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
  }
  .active {
    border-bottom: 3px solid #1989fa;
  }
}
.public {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 16px;
  overflow: hidden;
  color: #323233;
  font-size: 14px;
  line-height: 24px;
  background-color: #fff;
  .left_wrap {
    flex: none;
    box-sizing: border-box;
    width: 90px;
    text-align: left;
    .Left {
      margin-left: 17px;
      color: #323233;
      font-size: 14px;
      line-height: 24px;
    }
  }
  .right_wrap {
    flex: 1 0 auto;
    // margin-left:29px;
    box-sizing: border-box;
    text-align: left;
    width: 90px;
    .Right {
      color: #323233;
      font-size: 14px;
      line-height: 24px;
    }
  }
}
.left {
  float: left;
}
.clearfix::after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}
.clearfix {
  zoom: 1;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* 点击对应的标题添加对应的背景颜色 */
// .tab-content div {
//   font-size: 18px;
//   float: left;
//   // width: 25%;
//   line-height: 100px;
//   text-align: center;
// }
</style>
